Set ANSI_NULLS ON
Set QUOTED_IDENTIFIER ON
GO

/*Drop stored procedures if they exists */

IF EXISTS (SELECT name FROM sysobjects WHERE name = 'verificarNombreUnidaddeMedida' and type = 'P')

	BEGIN
		DROP PROCEDURE verificarNombreUnidaddeMedida
	END

GO

CREATE PROCEDURE verificarNombreUnidaddeMedida ( @nombreUnidaddeMedida VARCHAR (40) , 
										 @outParam INT OUTPUT						
										)
AS

	DECLARE @out AS INT;
	SET @out = -1;
	
	SELECT @out = UNIDAD_DE_MEDIDA.IDUNIDADDEMEDIDA 
	FROM UNIDAD_DE_MEDIDA
	WHERE UNIDAD_DE_MEDIDA.NOMBREUNIDADDEMEDIDA = @nombreUnidaddeMedida;	 
	
	SET @outParam = @out;

	SELECT @outParam;
GO